<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>提交留言</title>
<link type="text/css" href="${staticResources}/css/submitcomment.css" rel="stylesheet" />
<script type="text/javascript" src="${staticResources}/js/ajax.js"></script>
</head>
<script type="text/javascript">
function check()
{
	var title = document.getElementById("title").value;
	var content = document.getElementById("content").value;
	var redirect_url = document.getElementById("redirect_url").value;
	var mode = "ajax";
	
	var params="title=" + encodeURIComponent(title);
	params+="&content="+encodeURIComponent(content);
	params+="&redirect_url="+encodeURIComponent(redirect_url);
	params+="&mode="+encodeURIComponent(mode);
	
	if(title.length==0) {
		document.getElementById("tdmessage_1").innerHTML="<font color='red'>标题不能为空 </font>";
		return;
	}
	
	if(content.length==0) {
		document.getElementById("tdmessage_2").innerHTML="<font color='red'>内容不能为空 </font>";
		return;
	}
	
	doAjax("SubmitComment"
			,params,function(rst){
		var rst=eval('(' +rst+ ')');
		if (rst.status == 0)
		{
			location.href = rst.redirectURL;
			return;
		}
		document.getElementById("tdmessage_3").innerHTML = rst.message;
		return;
	 });
}

function setShowLength_1(maxlength) 
{ 
	var title = document.getElementById("title").value;
	var rem = maxlength- title.length; 
	if (rem < 0)
	{ 
	   rem = 0; 
	} 
	document.getElementById("tdmessage_1").innerHTML= "还可以输入" + rem + "字数"; 
} 

function setShowLength_2(maxlength) 
{ 
	var content = document.getElementById("content").value;
	var rem = maxlength- content.length; 
	if (rem < 0)
	{ 
	   rem = 0; 
	} 
	document.getElementById("tdmessage_2").innerHTML= "还可以输入" + rem + "字数"; 
} 
</script>

<body style=" background: url('${staticResources}/image/greenbc.gif');">
<div id="header">
  <div id="hy">
    <c:if test="${user eq null }">
    <div id="logo">欢迎光临中国药科大学二手书交易平台!请<span><a href="${contextPath }/Account/Login">登录</a></span> 免费<span><a href="${contextPath }/Account/Register">注册</a></span></div>
    </c:if>
    <c:if test="${user ne null }">
    <div id="sc">
      <ul>
        <li><a href="${contextPath }/Account/Logout">注销</a></li>
        <li><a href="${contextPath }/Me?content=201">收藏夹</a></li>
        <li><a href="${contextPath }/Me">个人中心</a></li>
        <li>欢迎你，<b>${fn:escapeXml(user.nickName) }</b>！</li>
      </ul>
    </div>
    </c:if>
  </div>
  <div id="top" style=" background: url('${staticResources}/image/listcommentsbc_03.gif');">
    <div class="tx">
	    <dl>
	     <c:choose>
           <c:when test="${empty user.userPicture }">
             <img src="${staticResources}/image/userpics_none.jpg" width="132" height="132" alt="">
           </c:when>
           <c:otherwise>
             <img src="${userContents}/userpics/${user.userPicture }" width="132" height="132" alt="">
           </c:otherwise>
	     </c:choose>
	    </dl>
	</div>
	<div class="xx">
	     <dl class="nc">${fn:escapeXml(user.nickName)}</dl>
		 <dl class="degree">活跃度：${user.activityPoint}</dl>
		 <dl class="degree">信誉度：${user.creditPoint}</dl>
		 <dl class="degree">个性签名：${fn:escapeXml(user.signature)}</dl>
	</div>
   </div>
 </div>
   <div id="nav" style=" background: url('${staticResources}/image/listcomments_07.gif');">
    <ul>
      <li><a href="${contextPath }/Homepage">首页</a></li>
      <li><a href="${contextPath }/Books/Search">交易广场</a></li>
      <li><a href="${contextPath }/Auctions/Search">拍卖中心</a></li>
      <li><a href="#">读者推荐</a></li>
      <li><a href="${contextPath }/Comment/ListComments">留言板</a></li>
      <li><a href="#">新手指南</a></li>
    </ul>
   </div>
<!--头部结束-->

<div class="main"  style=" background: url('${staticResources}/image/viewcomment_background2.jpg');">
  <form method="post" name="frmSubmitComment" action="SubmitComment" onsubmit="check();return false;">
    <table id="tableform" >
      <tr>
        <td  class="tdtext"><label>标题：</label></td>
        <td><input class="inputclass" type="text" id="title" size="70" maxlength="20" onkeyup="setShowLength_1(20)"/> </td>
        <td><label class="tdmessage" id="tdmessage_1"></label></td>
      </tr>
      <tr>
        <td valign="top"  class="tdtext"><label>内容：</label></td>
        <td><textarea rows="10" cols="55" id="content" name="content" class="inputclass" maxlength="300" onkeyup="setShowLength_2(300)"></textarea></td>
        <td valign="bottom"><label class="tdmessage" id="tdmessage_2"></label></td>
      </tr>
      <tr>
        <td  class="tdtext"><label></label></td>
        <td><input type="image" style=" margin-left:0px;"src="${staticResources}/image/submitcomment_03.gif" width="100" height="35" alt="" class="button"  name="commit" value="提交" class="inputclass"/></td>
        <td><label class="tdmessage" id="tdmessage_3"></label></td>
      </tr>
    </table>
    <input type="hidden" name="redirect_url" id="redirect_url" value="${su:encodeLink(param.redirect_url) }" />
  </form>
</div>
<!--中间部分结束-->

     <div class="bottom">中国药科大学版权所有</div>

<!--尾部结束-->


</body>
</html>